<?php
session_start();
if(!session_is_registered('lg'))
{
	session_register('lg');
	$_SESSION['lg'] = 'vn';
}
include('../language/'.$_SESSION['lg'].'.php');

include('../lib/PHPMailer/class.phpmailer.php');
global $mail;
//include("class.smtp.php"); // optional, gets called from within class.phpmailer.php if not already loaded
$mail = new PHPMailer();
$mail->IsSMTP(); // telling the class to use SMTP
$mail->Host       = "vansuong-vutuan.com.vn"; // SMTP server
//$mail->SMTPDebug  = 2;                     // enables SMTP debug information (for testing)
                                           // 1 = errors and messages
                                           // 2 = messages only
$mail->SMTPAuth   = true;                  // enable SMTP authentication
$mail->Port       = 25;                    // set the SMTP port for the GMAIL server
$mail->Username   = "mail@vansuong-vutuan.com.vn"; // SMTP account username
$mail->Password   = "123456";        // SMTP account password

$mail->SetFrom('mail@vansuong-vutuan.com.vn', 'Van Suong - Vu Tuan');
$mail->CharSet = "UTF-8"; 

$fh = fopen("../EmailTemplate/SendLink.html", 'r');
$template = fread($fh, filesize("../EmailTemplate/SendLink.html"));
fclose($fh);

$mail_to = $_GET['email'];
$mail_subject = 'Van Suong Vu Tuan xin chao ban';

$template = str_replace('[LINK]', $_GET['url'], $template);

$mail->SetFrom("info@vansuong-vutuan.com.vn", "Van Suong Vu Tuan");
$mail->Subject    = $mail_subject;
$mail->MsgHTML($template);
$mail->AddAddress( $mail_to, "Xin Chao");
//print($mail_to);
if(!$mail->Send()) {
  echo "Mailer Error: " . $mail->ErrorInfo;
} else {
  echo MAIL_SENDED;
}

//echo MAIL_SENDED;
?>